<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>4.数组去重</title>
</head>

<body>
  <script>
    const arr = [1, 2, 1, 3, 4, 3, 5, 3, 5, 6]
    // 1.indexOf方法
    function unique(arr) {
      let res = []
      arr.forEach((item) => {
        if (res.indexOf(item) === -1) {
          res.push(item)
        }
      })

      return res
    }
    console.log(unique(arr));

    // 2.set
    let set = new Set(arr)
    console.log([...set]);


  </script>

</body>

</html>